<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>24-document选择器</title>
  </head>
  <body>
    <button>单个选择器</button>
    <button>多个选择器</button>
    <button>标签选择器</button>
    <button class="btn">类选择器</button>
    <button id="id">id选择器</button>
    <button a="1">多条件选择器a=1</button>
    <button b="2">多条件选择器b=2</button>
    <button b="3">多条件选择器b=3</button>
    <button b="4">多条件选择器b=4</button>
    <script>
      // document.querySelector("button").onclick = ()=>{
      //     alert('单个选择器')
      // }

      //   document.querySelectorAll("button").forEach((item) => {
      //     item.onclick = () => {
      //       alert("全部选择器");
      //     };
      //   });
      //   document.querySelector(".btn").onclick = () => {
      //     alert("类选择器")
      //   }
      //   document.querySelector("#id").onclick = () => {
      //     alert("id选择器");
      //   };

    document.querySelector("button[b='2']").onclick =()=>{
        alert('条件为b="2"')
    }
    </script>
  </body>
</html>
